<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class Users_model extends CI_Model {

    

    function cek_user_login($username, $password) {
        $this->db->select('*');
        $this->db->where('NAMA', $username);
        $this->db->where('PASSWORD', md5($password));

        $query = $this->db->get($this->tabel_name, 1);



        if ($query->num_rows() == 1) {
            $this->db->limit(1);
            return $query->row_array();
        }
    }

    public function validasi()
    {
        $nama = $this->input->post('nama');
        $password = $this->input->post('password');
        $check = $this->users_model->check($nama, md5($password));
        if($check->num_rows() > 0)
        {
            //login berhasil, buat session
            //$this->session->set_userdata('username',$username);
            redirect('master_user');
        }
        else
        {
            //login gagal
            //$this->session->set_flashdata('message','Username atau password salah');
            redirect('users');
        }
    }

}

?>